from gm.api import *
import datetime

set_token("90be3f863b23ab3c1ef68d1f9b8dc06e4bebb30d")

day_time, hour_and_mins = str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')).split(' ')


index = 'SHSE.000016'

# 对股票池的选择
symbol_list = get_history_constituents(index=index, start_date=day_time)[0].get('constituents').keys()

# 从表单中提取因子
df = get_fundamentals_n(table='deriv_finance_indicator', symbols=symbol_list, end_date=day_time,
                        fields='NPGRT', count=1, df=True)

print(df.head())
